import { reactive, nextTick } from "vue"
import type { DialogModel, useDialogModel } from "../type/DialogModel"

export default function useDialog(): useDialogModel {
	const dialog = reactive<DialogModel>({
		visible: false,
		title: null,
		height: 280,
		width: 640,
		showCancel: true,
		showConfirm: true,
		showFooter: true,
	})
	const onClose = () => {
		nextTick(() => {
			dialog.visible = false
		})
	}
	const onConform = () => {
		nextTick(() => {
			dialog.visible = false
		})
	}
	const onOpen = () => {
		nextTick(() => {
			dialog.visible = true
		})
	}
	return {
		dialog,
		onOpen,
		onConform,
		onClose,
	}
}
